<template>
  <div class="message" v-if="show" @click="show = false">
    <div class="main">
        <div class="top" :class="text.length>1?'pad30':'pad49'">
            <span class="spanBlock" :style="{color:spanBlockColor}" v-for="item in text" :key="item">{{item}}</span>
        </div>
        <div class="operating flex-a">
            <span class="flex-a-j" @click.stop="cancelFn" v-text="cancelText" :style="{color:cancelColor}"></span>
            <span class="flex-a-j" @click.stop="confirmFn" v-text="confirmText" :style="{color:confirmColor}"></span>
        </div>
        <img v-if="showClose" src="@/assets/img/icon_pubilc_down.png" @click.stop="show = false" alt="">
    </div>
  </div>
</template>

<script>
export default {
    name:'message',
    data(){
        return {
            show: false,
            title: '', // 提示标题
            text: [], // 提示文本内容
            confirmText: '', // 确认按钮文本
            cancelText: '', // 取消按钮文本
            cancelColor:'',
            confirmColor:'',
            spanBlockColor:'',
            showClose:false,
            confirmFn () {}, // 确认方法
            cancelFn () {} // 取消方法
        }
    }
}
</script>

<style lang="less" scoped>
    .message {
        position: fixed;
        z-index: 9999;
        top: 0;
        right: 0;
        left: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        .flex-a {
            display: flex;
            align-items: center;
        }
        .flex-a-j {
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .main {
            width: 330px;
            height: 159px;
            background: #FFFFFF;
            border-radius: 7px;
            position: absolute;
            top: 50%;
            left: 50%;
            margin-left: -165px;
            margin-top: -80px;
            .top {
                width: 330px;
                height: 110px;
            }
            .pad30 {
                padding-top: 30px;
            }
            .pad49 {
                padding-top: 49px;
            }
            .operating {
                    width: 100%;
                    height: 49px;
                    border-top: 0.5px solid #ececec;
                    position: absolute;
                    bottom: 0;
                    left: 0;
                    color: #333333;
                    span {
                        height: 49px;
                        flex:1;
                        font-size: 18px;
                        &:nth-child(2){
                            border-left: 0.5px solid #ececec;
                        }
                    }
                }
            .spanBlock {
                display: block;
                font-size: 18px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                line-height: 24px;
                text-align: center;
                color: #333333;
            }
            img {
                width: 14px;
                height: 14px;
                position: absolute;
                top: 10px;
                right: 10px;
            }
        }
    }
</style>